<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2021.3.24
 * Time: 15:02
 */

class Solution
{
    public function reverse($int)
    {
        $res = 0;
        while ($int != 0) {
            $pop = $int % 10;
            $int = intval($int /  10);
            $res = $res * 10 + $pop;
        }
        if ($res > (pow(2,31)-1) || $res < pow(-2,31)) {
            return 0;
        }
        return $res;
    }
}
$res = (new Solution())->reverse($int);
